package com.zhouyang.imtest.controller;

import com.zhouyang.imtest.entity.Message;
import com.zhouyang.imtest.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:ZhouYang
 * @Description:
 * @Date: Created in 2020/7/16 15:46
 * @Modified By：
 */

@RestController
@RequestMapping("message")
@CrossOrigin
public class MessageController {

    @Autowired
    private MessageService messageService;

    /**
     * 拉取消息列表
     * @param fromId
     * @param toId
     * @param page
     * @param rows
     * @return
     */
    @GetMapping
    public List<Message> queryMessageList(@RequestParam("fromId") Long fromId, @RequestParam("toId") Long toId, @RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "rows", defaultValue = "10") Integer rows) {
        return messageService.queryMessageList(fromId, toId, page, rows);
    }
}
